#include "../../TestFunctions/src/KernelsTests.hpp"

#include "../../StlKernel/src/StlKernel.hpp"
#include "../../OpenMPKernel/src/OpenMpKernel.hpp"
#include "../../BoostKernel/src/BoostKernel.hpp"
#include "../../WinApiKernel/src/WinApiKernel.hpp"



int main(int argc, char* argv[])
{
	const size_t sizeArray = 200000000;

	std::vector<double> data;

	initializeData(data, sizeArray);

	typedef std::vector<double>::const_iterator DoubleIterator;

	std::function<bool (const DoubleIterator&)> isRequered = [&](const DoubleIterator& item){return (*item) > sizeArray / 2;};
	std::function<bool (const DoubleIterator&, const DoubleIterator&)> isNeedChange = [](const DoubleIterator& first, const DoubleIterator& second){return *first < *second;};

	std::map<std::string, const QDM::IKernel<DoubleIterator>*> kernels;
	typedef std::pair<std::string, const QDM::IKernel<DoubleIterator>* > KernelPair;

	const int countThreads = atoi(argv[1]);

	StlKernel<DoubleIterator> stlKernel;
	OpenMpKernel<DoubleIterator> openMpKernel;
	openMpKernel.setCountThreads(countThreads);

	BoostKernel<DoubleIterator> boostKernel;
	boostKernel.setCountThreads(countThreads);

	WinApiKernel<DoubleIterator> winApiKernel;
	winApiKernel.setCountThreads(countThreads);

	kernels.insert(KernelPair("StlKernel", &stlKernel));
	kernels.insert(KernelPair("OpenMpKernel", &openMpKernel));
	kernels.insert(KernelPair("BoostKernel", &boostKernel));
	kernels.insert(KernelPair("WinApiKernel", &winApiKernel));

	std::stringstream prefix;
	prefix << "Threads count - " << countThreads;

	kernelsSpeedTest("Log", data, kernels, isRequered, isNeedChange, prefix.str().c_str());

	return 0;
}